<template>
	<view class="page" :style="themeColor">
		<view class="flex benben-position-layout flex flex-wrap align-center cardAndSafe_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub cardAndSafe_fd0_0'>
				<view class='flex flex-wrap align-center'>
					<person></person>
				</view>
				<view class='flex flex-wrap align-stretch justify-center flex-sub'>
					<text class='cardAndSafe_fd0_0_c1_c0'>show me</text>
				</view>
				<view class='flex flex-wrap align-center cardAndSafe_fd0_0_c2'>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<!---账号与安全两列flex布局开始-->
		<view class="flex flex-direction flex-wrap align-stretch cardAndSafe_flex_1">
			<view style="padding: 8rpx 0;">
				<back :isQuery="1" @confirm="sereenConfirm"></back>
			</view>
		</view>
		<view class="result_info">
			<view class="result_left">
				<text class="result_left_1">{{city}}</text>
				<text>的伴游</text>
			</view>
			<view class="result_right">{{nums}}个结果</view>
		</view>

		<view class="select_mode">
			<view class="mode_left">
				<view class="mode_item" @tap.stop="change1">
					<text>年龄</text>
					<image v-if="age_order == 1" :src='STATIC_URL+"196.png"' mode="aspectFill"></image>
					<image v-if="age_order == 2" :src='STATIC_URL+"197.png"' mode="aspectFill"></image>
				</view>
				<view class="mode_item" @tap.stop="change2">
					<text>身高</text>
					<image v-if="height_order == 1" :src='STATIC_URL+"196.png"' mode="aspectFill"></image>
					<image v-if="height_order == 2" :src='STATIC_URL+"197.png"' mode="aspectFill"></image>
				</view>
				<view class="mode_item" @tap.stop="change3">
					<text>体重</text>
					<image v-if="weight_order == 1" :src='STATIC_URL+"196.png"' mode="aspectFill"></image>
					<image v-if="weight_order == 2" :src='STATIC_URL+"197.png"' mode="aspectFill"></image>
				</view>
			</view>
			<view class="mode_right" @tap.stop="show=true">
				<text>筛选</text>
				<image :src='STATIC_URL+"103.png"' mode="aspectFill"></image>
			</view>
		</view>
		<view class="loading_css" v-if="isShow">
			<u-loading size="36" color="#6A0002"></u-loading>
			<view class="loading_text">加载中</view>
		</view>
		<!-- 推荐用户列表 -->
		<template v-else>
			<view class="user_list">
				<view class="list_item" v-for="(item, index) in list" :key="index" @tap.stop="handleJumpDiy" data-type="navigateTo" :data-url="`/pages/home/userDetails/index?id=${item.id}`">
					
					<view style="position: relative;">
						<image class="image_1" :src='item.image' mode="aspectFill"></image>
						<view class="certified" v-if="item.is_real_person_auth == 1">
							已认证
						</view>
						<image v-if="item.is_video == 1" class="play_btn" :src='STATIC_URL+"97.png"' mode="aspectFill"></image>
					</view>
					<view class="item_name">
						<image class="image_2" :src='item.head_img' mode="aspectFill"></image>
						<view>{{item.user_nickname}}</view>
					</view>
				</view>
			</view>
			<u-loadmore v-if="last_page > 1" class="loadmore" font-size="24" :status="status" :icon-type="iconType"
				:load-text="loadText" />
			<view class="noData_other" v-if="list.length == 0 && !isShow">
				<image src="/static/empty/no.png"></image>
			</view>
		</template>

		<u-popup v-model="show" mode="right" z-index="5" width="630">
			<view class="popup_info" :style="{paddingTop:(StatusBarRpx + 192)+'rpx'}">
				<view class="search_item">
					<view class="search_item_left">
						搜索名称
					</view>
					<view class="search_item_right">
						<input placeholder="请输入" type="text" v-model="name">
					</view>
				</view>
				<view class="search_item">
					<view class="search_item_left">
						电话
					</view>
					<view class="search_item_right">
						<input placeholder="请输入" type="text" v-model="mobile">
					</view>
				</view>
				<view class="search_item">
					<view class="search_item_left">
						身高
					</view>
					<view class="search_item_right">
						<zxz-uni-data-select :placeholder="'请选择'" v-model="height" :localdata="height_option" dataKey="label" dataValue="value" @change="selectHeight"></zxz-uni-data-select>
					</view>
				</view>
				<view class="search_item">
					<view class="search_item_left">
						体重
					</view>
					<view class="search_item_right">
						<zxz-uni-data-select :placeholder="'请选择'" v-model="weight" :localdata="weight_option" dataKey="label" dataValue="value" @change="selectWeight"></zxz-uni-data-select>
					</view>
				</view>
				<view class="search_item">
					<view class="search_item_left">
						年龄
					</view>
					<view class="search_item_right">
						<zxz-uni-data-select :placeholder="'请选择'" v-model="age" :localdata="age_option" dataKey="label" dataValue="value" @change="selectAge"></zxz-uni-data-select>
					</view>
				</view>
				<!-- <view class="age_item">
					<view class="age_item_left">年龄</view>
					<view class="age_item_right">
						<view class="age_select">
							<input type="text">
							<u-icon name="arrow-down" color="#999"></u-icon>
						</view>
						<text>-</text>
						<view class="age_select">
							<input type="text">
							<u-icon name="arrow-down" color="#999"></u-icon>
						</view>
					</view>
				</view> -->
				<view class="search_item">
					<view class="search_item_left">
						性取向
					</view>
					<view class="search_item_right">
						<zxz-uni-data-select :placeholder="'请选择'" v-model="sexual_orientation" :localdata="sexual_orientation_option" dataKey="label" dataValue="value" @change="selectSexual"></zxz-uni-data-select>
					</view>
				</view>
				<view class="search_item">
					<view class="search_item_left">
						肤色
					</view>
					<view class="search_item_right">
						<zxz-uni-data-select :placeholder="'请选择'" v-model="skin_color" :localdata="skin_color_option" dataKey="label" dataValue="value" @change="selectSkinColor"></zxz-uni-data-select>
					</view>
				</view>
				<!-- <view class="add_item">
					<view class="add_item_left">国籍</view>
					<view class="add_item_right">
						<view class="add_btn">
							<image :src='STATIC_URL+"104.png"' mode="aspectFill"></image>
							<text>添加</text>
						</view>
					</view>
				</view> -->
				<view class="search_item">
					<view class="search_item_left">
						胸围
					</view>
					<view class="search_item_right">
						<zxz-uni-data-select :placeholder="'请选择'" v-model="bust" :localdata="bust_option" dataKey="label" dataValue="value" @change="selectBust"></zxz-uni-data-select>
					</view>
				</view>
				<!-- <view class="search_item">
					<view class="search_item_left">
						头发
					</view>
					<view class="search_item_right">
						<zxz-uni-data-select :placeholder="'请选择'" v-model="hair" :localdata="hair_option" dataKey="label" dataValue="value" @change="selectHair"></zxz-uni-data-select>
					</view>
				</view> -->
				<!-- <view class="search_item">
					<view class="search_item_left">
						眼睛
					</view>
					<view class="search_item_right">
						<zxz-uni-data-select :placeholder="'请选择'" v-model="eye" :localdata="eye_option" dataKey="label" dataValue="value" @change="selectEye"></zxz-uni-data-select>
					</view>
				</view> -->
				<view class="search_item">
					<view class="search_item_left">
						兴趣见面
					</view>
					<view class="search_item_right">
						<zxz-uni-data-select :placeholder="'请选择'" v-model="interest_meet" :localdata="interest_meet_option" dataKey="label" dataValue="value" @change="selectMeet"></zxz-uni-data-select>
					</view>
				</view>
				<!-- <view class="add_item">
					<view class="add_item_left">语言</view>
					<view class="add_item_right">
						<view class="add_btn">
							<image :src='STATIC_URL+"104.png"' mode="aspectFill"></image>
							<text>添加</text>
						</view>
					</view>
				</view>
				<view class="add_item">
					<view class="add_item_left">时间</view>
					<view class="add_item_right">
						<view class="add_btn">
							<image :src='STATIC_URL+"104.png"' mode="aspectFill"></image>
							<text>添加</text>
						</view>
					</view>
				</view> -->
				<view class="search_item">
					<view class="search_item_left">
						抽烟
					</view>
					<view class="search_item_right">
						<zxz-uni-data-select :placeholder="'请选择'" v-model="smoke" :localdata="smoke_option" dataKey="label" dataValue="value" @change="selectSmoke"></zxz-uni-data-select>
					</view>
				</view>
				<view class="search_item">
					<view class="search_item_left">
						喝酒
					</view>
					<view class="search_item_right">
						<zxz-uni-data-select :placeholder="'请选择'" v-model="drink" :localdata="drink_option" dataKey="label" dataValue="value" @change="selectDrink"></zxz-uni-data-select>
					</view>
				</view>
				<!-- <view class="search_item">
					<view class="search_item_left">
						脱毛
					</view>
					<view class="search_item_right">
						<zxz-uni-data-select :placeholder="'请选择'" v-model="molt" :localdata="molt_option" dataKey="label" dataValue="value" @change="selectMolt"></zxz-uni-data-select>
					</view>
				</view> -->
				<view style="height: 100rpx;"></view>
			</view>
		</u-popup>

	</view>
</template>
<script>
	import back from "@/components/back/index.vue"
	import person from "@/components/person/index.vue"
	import recommend from "@/components/recommend/index.vue"
	export default {
		components: {
			back,
			person,
			recommend
		},


		data() {
			return {
				show: false,
				name: "",
				mobile: "",
				country: "",
				city: "",
				nums: 0,
				age_order: 1,  // 年龄排序：0=默认，1=升序，2=降序
				height_order: 1, // 身高排序：0=默认，1=升序，2=降序
				weight_order: 1, // 体重排序：0=默认，1=升序，2=降序
				
				"list": [],
				"page": 1,
				"is_pull": true,
				"last_page": 1,
				"status": 'loadmore',
				"iconType": 'flower',
				"loadText": {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
				"isShow": true,
				
				sex_option: [],  // 性别
				sexual_orientation_option: [],  // 性取向
				interest_meet_option: [],  // 兴趣见面
				age_option: [],  // 年龄
				height_option: [],  // 身高
				weight_option: [],  // 体重
				bust_option: [],  // 胸围
				skin_color_option: [],  // 肤色
				hair_option: [],  // 头发
				eye_option: [],  // 眼睛
				molt_option: [],  // 脱毛
				lang_option: [],  // 语言
				lang_level_option: [],  // 语言水平
				week_option: [],  // 星期几
				smoke_option: [],  // 抽烟
				drink_option: [],  // 喝酒
				nationalityList: [],  // 国家列表
				cityList: [],  // 城市列表
				
				height: "",
				weight: "",
				age: "",
				sexual_orientation: "",
				skin_color: "",
				bust: "",
				hair: "",
				eye: "",
				interest_meet: "",
				smoke: "",
				drink: "",
				molt: "",
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {country, city} = options;
			if (country !== undefined) this.country = country;
			if (city !== undefined) this.city = city;
			this.getConfiguration();
			this.getCityNum();
			this.getUserList();
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = true;
			this.getUserList();
		},
		// 上拉加载
		onReachBottom() {
			if (this.page >= this.last_page) return;
			this.status = 'loading';
			this.page++;
			setTimeout(() => {
		
				if (this.page >= this.last_page) this.status = 'nomore';
				else this.status = 'loading';
				this.is_pull = false;
				this.getUserList();
			}, 500)
		},
		onPageScroll(e) {

		},
		methods: {
			// 获取配置信息  post659ce5e3a1de8
			getConfiguration() {
				this.$api.post(global.apiUrls.post659ce5e3a1de8, {
					
				}).then(res => {
					// console.log(res);
					if (res.data.code == 1) {
						this.sex_option = res.data.data.sex_option;
						this.sexual_orientation_option = res.data.data.sexual_orientation_option;
						this.interest_meet_option = res.data.data.interest_meet_option;
						this.age_option = res.data.data.age_sift_option;
						this.height_option = res.data.data.height_option;
						this.weight_option = res.data.data.weight_option;
						this.bust_option = res.data.data.bust_option;
						this.skin_color_option = res.data.data.skin_color_option;
						this.hair_option = res.data.data.hair_option;
						this.eye_option = res.data.data.eye_option;
						this.molt_option = res.data.data.molt_option;
						this.lang_option = res.data.data.lang_option;
						this.lang_level_option = res.data.data.lang_level_option;
						this.week_option = res.data.data.week_option;
						this.smoke_option = res.data.data.smoke_option;
						this.drink_option = res.data.data.drink_option;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 数量  post65a0eb895ae78
			getCityNum() {
				this.$api.post(global.apiUrls.post65a0eb895ae78, {
					country: this.country,
					city: this.city
				}).then(res => {
					// console.log(res);
					if (res.data.code == 1) {
						this.nums = res.data.data.nums;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 用户列表   post65a0fd357444d
			getUserList() {
				this.$api.post(global.apiUrls.post65a0fd357444d,{
					page: this.page,
					country: this.country,
					city: this.city,
					user_nickname: this.name,
					mobile: this.mobile,
					height: this.height,
					weight: this.weight,
					age: this.age,
					skin_color: this.skin_color,
					bust: this.bust,
					hair: this.hair,
					eye: this.eye,
					interest_meet: this.interest_meet,
					sexual_orientation: this.sexual_orientation,
					molt: this.molt,
					smoke: this.smoke,
					drink: this.drink,
					age_order: this.age_order,
					height_order: this.height_order,
					weight_order: this.weight_order
				}).then(res => {
					// console.log(res);
					if (res.data.code == 1) {
						uni.stopPullDownRefresh();
						this.isShow = false;
						if (res.data.code == 1) {
							this.last_page = res.data.data.last_page;
							if (this.is_pull) {
								this.list = res.data.data.data;
							} else {
								this.list = this.list.concat(res.data.data.data);
							}
						} else {
							this.$message.info(res.data.msg);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			
			
			change1() {
				if (this.age_order == 1) {
					this.age_order = 2;
				} else {
					this.age_order = 1;
				}
				this.page = 1;
				this.is_pull = true;
				this.isShow = true;
				this.getUserList();
			},
			change2() {
				if (this.height_order == 1) {
					this.height_order = 2;
				} else {
					this.height_order = 1;
				}
				this.page = 1;
				this.is_pull = true;
				this.isShow = true;
				this.getUserList();
			},
			change3() {
				if (this.weight_order == 1) {
					this.weight_order = 2;
				} else {
					this.weight_order = 1;
				}
				this.page = 1;
				this.is_pull = true;
				this.isShow = true;
				this.getUserList();
			},
			// 选择性取向
			selectSexual(e) {
				this.sexual_orientation = e.value;
			},
			// 选择我的兴趣见面
			selectMeet(e) {
				this.interest_meet = e.value;
			},
			// 选择肤色
			selectSkinColor(e) {
				this.skin_color = e.value;
			},
			// 选择国籍
			selectCountry(e) {
				this.nationality = e.label;
			},
			// 选择头发
			selectHair(e) {
				this.hair = e.value;
			},
			// 选择眼睛
			selectEye(e) {
				this.eye = e.value;
			},
			// 选择身高
			selectHeight(e) {
				this.height = e.value;
			},
			// 选择体重
			selectWeight(e) {
				this.weight = e.value;
			},
			// 选择年龄
			selectAge(e) {
				this.age = e.value;
			},
			// 选择胸围
			selectBust(e) {
				this.bust = e.value;
			},
			// 选择脱毛类型
			selectMolt(e) {
				this.molt = e.value;
			},
			// 选择抽烟
			selectSmoke(e) {
				this.smoke = e.value;
			},
			// 选择喝酒
			selectDrink(e) {
				this.drink = e.value;
			},
			// 筛选确定
			sereenConfirm() {
				this.show = false;
				this.page = 1;
				this.is_pull = true;
				this.isShow = true;
				this.getUserList();
			},
		}
	};
</script>
<style lang="scss" scoped>
	.user_list {
		margin: 0 32rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		.list_item {
			background: #fff;
			border-radius: 16rpx;
			margin-bottom: 16rpx;
			width: 336rpx;
			.image_1 {
				width: 336rpx;
				height: 336rpx;
				border-radius: 16rpx 16rpx 0 0;
			}
			.item_name {
				padding: 25rpx 0 25rpx 20rpx;
				display: flex;
				align-items: center;
				font-size: 24rpx;
				.image_2 {
					width: 36rpx;
					height: 36rpx;
					margin-right: 12rpx;
					border-radius: 50%;
				}
			}
			.play_btn {
				width: 64rpx;
				height: 64rpx;
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translate(-50%,-50%);
			}
			.certified {
				position: absolute;
				top: 0;
				right: 0;
				width: 108rpx;
				height: 48rpx;
				background: rgba(0, 0, 0, 0.5);
				border-radius: 0px 16rpx 0px 16rpx;
				font-size: 24rpx;
				color: #fff;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			.item_date_info {
				padding: 0 20rpx;
				.item_date {
					padding: 24rpx 0rpx;
					font-size: 22rpx;
					color: #999;
					border-top: 1rpx solid #eee;
				}
			}
			
		}
	}
	.popup_info {
		padding: 20rpx 40rpx 20rpx 32rpx;
		.search_item {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20rpx 0;
			.search_item_left {
				font-size: 28rpx;
			}
			.search_item_right {
				width: 421rpx;
				height: 64rpx;
				background: #F8F8F8;
				border-radius: 8rpx;
				display: flex;
				input {
					height: 100%;
					font-size: 24rpx;
					padding: 0 20rpx 0 24rpx;
				}
				
				// padding: 0 20rpx 0 24rpx;
			}
		}
		.age_item {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20rpx 0;
			.age_item_left {
				font-size: 28rpx;
			}
			.age_item_right {
				width: 421rpx;
				height: 64rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				.age_select {
					width: 200rpx;
					height: 64rpx;
					background: #F8F8F8;
					border-radius: 8rpx;
					padding: 0 20rpx 0 24rpx;
					display: flex;
					align-items: center;
				}
			}
		}
		.add_item {
			display: flex;
			justify-content: space-between;
			padding: 20rpx 0;
			.add_item_left {
				font-size: 28rpx;
			}
			.add_item_right {
				width: 421rpx;
				height: 88rpx;
				background: #F8F8F8;
				border-radius: 8rpx;
				padding: 22rpx 24rpx;
				.add_btn {
					display: flex;
					align-items: center;
					font-size: 24rpx;
					color: #666;
					width: 107rpx;
					height: 45rpx;
					border-radius: 8rpx;
					border: 1px solid #BFBFBF;
					image {
						width: 24rpx;
						height: 24rpx;
					}
				}
			}
		}
	}
	
	.result_info {
		width: 686rpx;
		height: 88rpx;
		border-radius: 12rpx;
		opacity: 1;
		border: 2rpx solid #BFBFBF;
		margin: 23rpx 32rpx 24rpx 32rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 24rpx;

		.result_left {
			font-size: 28rpx;

			.result_left_1 {
				color: #E62E2E;
			}
		}

		.result_right {
			font-size: 28rpx;
		}
	}

	.select_mode {
		background: #fff;
		padding: 24rpx 32rpx;
		display: flex;
		justify-content: space-between;
		margin-bottom: 24rpx;

		.mode_left {
			flex: 1;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding-right: 110rpx;

			.mode_item {
				display: flex;
				align-items: center;
				font-size: 28rpx;

				image {
					width: 12rpx;
					height: 20rpx;
					margin-left: 8rpx;
				}
			}
		}

		.mode_right {
			display: flex;
			align-items: center;
			font-size: 28rpx;

			image {
				width: 28rpx;
				height: 28rpx;
				margin-left: 8rpx;
			}
		}
	}



	.home_img {
		width: 40rpx;
		height: 40rpx;
	}

	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: linear-gradient(181deg, #FFFFFF 0%, #F8F8F8 100%);
		background-size: 100% auto !important;
	}

	.cardAndSafe_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.cardAndSafe_fd0_0_c2 {
		width: 40rpx;
		height: 40rpx;
	}

	.cardAndSafe_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: bold;
		color: #333;
		line-height: 88rpx;
	}

	.cardAndSafe_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
		line-height: 88rpx;
	}

	.cardAndSafe_fd0_0 {
		margin: 0rpx 32rpx 0rpx 32rpx;
	}

	.cardAndSafe_flex_1 {
		background: #fff;
		font-size: 32rpx;
		background-size: 100% auto !important;
		padding: 0rpx 32rpx 0rpx 32rpx;
		position: relative;
		z-index: 5;
	}

	.cardAndSafe_fd1_3 {
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.cardAndSafe_fd1_0_c1 {
		font-size: 26rpx;
		color: rgba(191, 191, 191, 1);
		font-weight: 400;
	}

	.cardAndSafe_fd1_0_c0 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.cardAndSafe_fd1_0 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.cardAndSafe_flex_2 {
		height: 88rpx;
		position: fixed;
		bottom: 64rpx;
		left: 30rpx;
	}

	.cardAndSafe_fd2_0 {
		background: #6A0002;
		border-radius: 44rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #fff;
		width: 690rpx;
		height: 88rpx;
		line-height: 88rpx;
	}
</style>